<template>
    <div>
<h3>排房</h3>
<table>
    <tbody>
        <tr>
            <td>房型</td>
            <td>
                <select v-model="queryInfo.TypeEng">
                    <option :value="0">请选择</option>
                    <option v-for="item in Type" :value="item.RoomId">{{item.RoomName}}</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>房号</td>
            <td>
                <select v-model="queryInfo.RoomEng">
                    <option :value="0">请选择</option>
                    <option v-for="Dream in Nub" :value="Dream.NubId">{{Dream.NubCard}}</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <input type="button" class="btn btn-primary" value="提交" @click="AddInsert"/>
            </td>
            <td></td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref,reactive,onMounted } from 'vue';
import { useRouter,useRoute } from 'vue-router';
import axios from 'axios';
import moment from 'moment';
const Router=useRouter();
const Route=useRoute();
let queryInfo=reactive({
    RoomEng:0,
    TypeEng:0
})
onMounted(()=>{
    NubShow();
    TypeShow();
})
///房型添加
const AddInsert=()=>{

    axios({
    url:'/api/Room/RoomAdd',
    method:'post',
    data:queryInfo
    })
    .then((res)=>{
        console.log(res.data);
        if(res.data==1){
            alert("提交成功！");
            Router.push('/typeList')
        }
    })
    .catch((err)=>{
        console.log(err)
    })
}
let Nub:any=ref([]);
const NubShow=()=>{
    axios({
        url:'/api/Nub/NubShow',
        method:'get'
    })
    .then((res)=>{
        console.log(res.data)
        Nub.value=res.data
    })
    .catch((err)=>{
        console.log(err)
    })
}
let Type:any=ref([]);
const TypeShow=()=>{
    axios({
        url:'/api/Type/SelectShow',
        method:'get'
    })
    .then((res)=>{
        console.log(res.data)
        Type.value=res.data
    })
    .catch((err)=>{
        console.log(err)
    })
}
</script>

<style scoped>

</style>